package com.work.daily.stream;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;

/**
 * Stream 的聚合（max/min/count)
 *
 * @author Shengkang.Mo
 * @create 2020-11-23 16:33
 */
public class Stream_4_1 {
    public static void main(String[] args) {
        List<String> list = Arrays.asList("adnm", "admmt", "pot", "xbangd", "weoujgsd");
        Optional<String> max = list.stream().max(Comparator.comparing(String::length));
        System.out.println("最长的字符串：" + max.get());

        Optional<String> min = list.stream().min(Comparator.comparing(String::length));
        System.out.println("最短字符串：" + min.get());
    }
}
